package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

//将io包下的每一个文件都输出到控制台上
public class Test3 {
    public static void main(String[] args) throws IOException {
     /*   File dir=new File("./src/io");
        if (dir.isDirectory()){
            File[] subs=  dir.listFiles(f->f.getName().endsWith(".java"));//过滤器以。java结尾
            for (int i=0;i<subs.length;i++){
                FileInputStream fis=new FileInputStream(subs[i]);
                long len=subs[i].length();
                System.out.println("文件大小为"+len);
                byte[] data=new byte[(int)len];
                fis.read(data);
                String line=new String(data, StandardCharsets.UTF_8);
                System.out.println(line);
                fis.close();
            }

        }
*/
           File dir=new File("./src/io");
           if (dir.isDirectory()){
               File[] subs=dir.listFiles(f->f.getName().endsWith(".java"));
               for (int i=0;i<subs.length;i++){
                   FileInputStream fis=new FileInputStream(subs[i]);
                   long len=subs[i].length();
                   System.out.println("大小"+len);
                   byte[] data=new byte[(int)len];
                   fis.read(data);
                   String line=new String(data,StandardCharsets.UTF_8);
                   System.out.println(line);
                   fis.close();
               }

           }









    }
}